"use strict";
cc._RF.push(module, '1aaab0sjJJKoqojBFBQKZfG', 'level_peopleArcheryOption');
// scripts/levelBundles/level_PeopleArchery/unit/level_peopleArcheryOption.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../../../engines/gameEngine");
var level_PeopleArcheryUnitBase_1 = require("../base/level_PeopleArcheryUnitBase");
var peopleArcheryConst_1 = require("../const/peopleArcheryConst");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var level_peopleArcheryOption = /** @class */ (function (_super) {
    __extends(level_peopleArcheryOption, _super);
    function level_peopleArcheryOption() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**数据 */
        _this.data = null;
        _this.lastWaveFlag = false;
        _this.firstFlag = false;
        _this.lbText = null;
        _this.showSp = null;
        _this.normalShowSps = [];
        _this.xianMoShowSps = [];
        _this.moShowSps = [];
        _this.xianShowSps = [];
        _this.dujieShowSps = [];
        _this.dujieTitle = null;
        _this.arrowAddSpf = [];
        _this.arrowSubSpf = [];
        _this.arrowSp = null;
        /*
         *选择门类型
         * 0 普通门 1仙门 2魔门
        */
        _this.optionType = "0";
        _this.colorAry = [
            cc.color(24, 91, 153),
            cc.color(204, 41, 109),
        ];
        _this.groupOption = [];
        _this.wavaData = null;
        _this.groupIndex = 0;
        _this.surviveCatastropheData = null;
        return _this;
    }
    level_peopleArcheryOption_1 = level_peopleArcheryOption;
    /**
     * 绑定数据
     * @param data 数据
     * @param lastWaveFlag  是否是最一波
     * @param type 门类型
     * @param firstFlag 是否是第一扇变身的门
     */
    level_peopleArcheryOption.prototype.bindData = function (data, lastWaveFlag, type, firstFlag, groupIndex, waveData, surviveCatastropheData) {
        this.optionType = type;
        this.data = data;
        this.firstFlag = firstFlag;
        this.lastWaveFlag = lastWaveFlag;
        this.groupIndex = groupIndex;
        this.wavaData = waveData;
        this.surviveCatastropheData = surviveCatastropheData;
        var dujieTitle = this.dujieTitle.getChildByName("lbTitle").getComponent(cc.Label);
        dujieTitle.string = this.surviveCatastropheData ? "" + this.surviveCatastropheData.surviveCatastrophe_name : "";
        this.refrenshOption();
    };
    level_peopleArcheryOption.prototype.start = function () {
        this.dujieTitle.active = this.surviveCatastropheData && this.node.x <= 0;
    };
    /**刷新选项 */
    level_peopleArcheryOption.prototype.refrenshOption = function () {
        switch (this.optionType) {
            case "0": {
                var str = gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsOptionText(this.data); // +"\n" + O1HD.getManagers().peopleArcheryManager.parseDataAsParamText(this.data);
                this.lbText.string = str;
                var param = gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsParam(this.data);
                if (param >= 0) {
                    this.arrowSp.spriteFrame = this.arrowAddSpf[Number(this.data.arrow_level)];
                    this.showSp.spriteFrame = this.normalShowSps[0];
                    this.lbText.node.getComponent(cc.LabelOutline).color = this.colorAry[0];
                }
                else {
                    this.showSp.spriteFrame = this.normalShowSps[1];
                    this.arrowSp.spriteFrame = this.arrowSubSpf[Number(this.data.arrow_level)];
                    this.lbText.node.getComponent(cc.LabelOutline).color = this.colorAry[1];
                }
                break;
            }
            case "1": {
                this.lbText.node.x = 0;
                if (this.firstFlag) {
                    this.showSp.spriteFrame = this.xianMoShowSps[0];
                    this.lbText.string = "";
                }
                else {
                    this.showSp.spriteFrame = this.xianMoShowSps[0];
                    var param = gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsParam(this.data);
                    if (param >= 0) {
                        this.showSp.spriteFrame = this.xianShowSps[0];
                        this.lbText.node.getComponent(cc.LabelOutline).color = this.colorAry[0];
                    }
                    else {
                        this.showSp.spriteFrame = this.xianShowSps[0];
                        this.lbText.node.getComponent(cc.LabelOutline).color = this.colorAry[1];
                    }
                    var str = gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsOptionText(this.data) + "\n" + gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsParamText(this.data);
                    this.lbText.string = str;
                }
                break;
            }
            case "2": {
                this.lbText.node.x = 0;
                if (this.firstFlag) {
                    this.showSp.spriteFrame = this.xianMoShowSps[1];
                    this.lbText.string = "";
                }
                else {
                    var param = gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsParam(this.data);
                    if (param >= 0) {
                        this.showSp.spriteFrame = this.moShowSps[0];
                        this.lbText.node.getComponent(cc.LabelOutline).color = this.colorAry[0];
                    }
                    else {
                        this.showSp.spriteFrame = this.moShowSps[1];
                        this.lbText.node.getComponent(cc.LabelOutline).color = this.colorAry[1];
                    }
                    var str = gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsOptionText(this.data) + "\n" + gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsParamText(this.data);
                    this.lbText.string = str;
                }
                break;
            }
        }
        if (!this.surviveCatastropheData) {
            return;
        }
        var optionRealType = this.surviveCatastropheData.option_Type;
        var chats = this.surviveCatastropheData["surviveCatastrophe_option_chats"].split("|");
        var chat = chats[this.groupIndex];
        switch (optionRealType) {
            case "2": {
                this.showSp.spriteFrame = this.dujieShowSps[0];
                this.lbText.string = chat;
                this.lbText.node.getComponent(cc.LabelOutline).color = cc.color(135, 10, 1);
                this.arrowSp.spriteFrame = null;
                break;
            }
            case "3": {
                this.showSp.spriteFrame = this.dujieShowSps[1];
                this.lbText.string = chat;
                this.lbText.node.getComponent(cc.LabelOutline).color = cc.color(3, 39, 59);
                this.arrowSp.spriteFrame = null;
                break;
            }
            case "4": {
                this.showSp.spriteFrame = this.dujieShowSps[2];
                this.lbText.string = chat;
                this.lbText.node.getComponent(cc.LabelOutline).color = cc.color(1, 98, 151);
                this.arrowSp.spriteFrame = null;
                break;
            }
            case "5": {
                this.showSp.spriteFrame = this.dujieShowSps[3];
                this.lbText.string = chat;
                this.lbText.node.getComponent(cc.LabelOutline).color = cc.color(237, 55, 125);
                this.arrowSp.spriteFrame = null;
                break;
            }
        }
    };
    level_peopleArcheryOption.prototype.update = function (dt) {
        if (this.level.gamePauseFlag) {
            return;
        }
        var moveDis = this.level.getRoleMoveSpd() * dt;
        this.node.y -= moveDis;
        this.autoDeath();
        _super.prototype.update.call(this, dt);
    };
    level_peopleArcheryOption.prototype.onCollisionEnter = function (other, self) {
        if (other.tag == peopleArcheryConst_1.peopleArcheryUnitTag.people) {
            var param = gameEngine_1.default.getManagers().peopleArcheryManager.parseDataAsParam(this.data);
            if (param >= 0) {
                gameEngine_1.default.getManagers().soundMgr.playSound("peopleArcherySound/Door");
            }
            else {
                gameEngine_1.default.getManagers().soundMgr.playSound("peopleArcherySound/RedDoor");
            }
            if (this.lastWaveFlag) {
                // this.level.gameWin();
                // if(this.lastWaveFlag){
                // 打开获得修为界面
                this.level.openMoneyPage();
            }
        }
    };
    level_peopleArcheryOption.prototype.clearGroupOption = function () {
        for (var _i = 0, _a = this.groupOption; _i < _a.length; _i++) {
            var option = _a[_i];
            if (this.node.uuid != option.uuid) {
                var os = option.getComponent(level_peopleArcheryOption_1);
                os.data = null;
                os.unitDeath();
            }
        }
    };
    var level_peopleArcheryOption_1;
    __decorate([
        property({ type: cc.Label, tooltip: "显示文案" })
    ], level_peopleArcheryOption.prototype, "lbText", void 0);
    __decorate([
        property({ type: cc.Sprite, tooltip: "显示图片" })
    ], level_peopleArcheryOption.prototype, "showSp", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "显示的图片" })
    ], level_peopleArcheryOption.prototype, "normalShowSps", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "仙魔显示的图片" })
    ], level_peopleArcheryOption.prototype, "xianMoShowSps", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "魔显示的图片" })
    ], level_peopleArcheryOption.prototype, "moShowSps", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "仙显示的图片" })
    ], level_peopleArcheryOption.prototype, "xianShowSps", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "渡劫显示的门" })
    ], level_peopleArcheryOption.prototype, "dujieShowSps", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "渡劫标题" })
    ], level_peopleArcheryOption.prototype, "dujieTitle", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "加属性的箭头图片" })
    ], level_peopleArcheryOption.prototype, "arrowAddSpf", void 0);
    __decorate([
        property({ type: cc.SpriteFrame, tooltip: "减属性的箭头图片" })
    ], level_peopleArcheryOption.prototype, "arrowSubSpf", void 0);
    __decorate([
        property({ type: cc.Sprite, tooltip: "箭头显示节点" })
    ], level_peopleArcheryOption.prototype, "arrowSp", void 0);
    level_peopleArcheryOption = level_peopleArcheryOption_1 = __decorate([
        ccclass
    ], level_peopleArcheryOption);
    return level_peopleArcheryOption;
}(level_PeopleArcheryUnitBase_1.default));
exports.default = level_peopleArcheryOption;

cc._RF.pop();